Scroll Progress Bar

Continue

The continue keyword is used inside loops to skip the rest of the current iteration and move on to the next iteration.

Usage: It is used to control the flow within a loop, particularly when you want to skip certain iterations based on a condition.

Syntax: continue;

Example with comments and output:

#include <stdio.h>

int main() {
    for (int i = 0; i < 5; i++) {
        if (i == 2) {
            continue; // Skip iteration when 'i' is 2
        }
        printf("Iteration: %d\n", i);
    }
    return 0;
}
Output:

Iteration: 0
Iteration: 1
Iteration: 3
Iteration: 4

What is the purpose of the 'continue' statement in C?


Skip

Where is the 'continue' statement used in loops?


Loops

What does the 'continue' statement do when executed?


Iteration